package jschool.util;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;
import javax.swing.border.Border;

public class PintaImagen implements Border {

	private BufferedImage image;
	private JPanel panel;
	public PintaImagen(BufferedImage image, JPanel panel) {
		this.image = image;
		this.panel = panel;
	}

	public void paintBorder(Component c, Graphics g, int x, int y,
			int width, int height) {
		Dimension tamanio = panel.getSize();
		width = tamanio.width;
		height = tamanio.height;
		g.drawImage(image, 0, 0, tamanio.width, tamanio.height, null);
		panel.setOpaque(false);
		panel.paintComponents(g);
	}

	public Insets getBorderInsets(Component c) {
		return new Insets(0, 0, 0, 0);
	}

	public boolean isBorderOpaque() {
		return true;
	}

}
